
package jtrimet;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

class XStreamFactory
{
	public static XStream createXStream()
	{
		
		XStream xstream = new XStream(new DomDriver());
		
		xstream.autodetectAnnotations(true);

		xstream.addImplicitCollection(BlockPosition.class, "trips", Trip.class);

		xstream.alias("resultSet", Response.class);
		xstream.alias("location", Location.class);
		xstream.alias("blockPosition", BlockPosition.class);
		xstream.alias("trip", Trip.class);
		xstream.alias("layover", Layover.class);
		
		xstream.aliasAttribute(Location.class, "latitude", "lat");
		xstream.aliasAttribute(Location.class, "locationId", "locid");
		xstream.aliasAttribute(Location.class, "longitude", "lng");
		xstream.aliasAttribute(Location.class, "description", "desc");
		xstream.aliasAttribute(Location.class, "direction", "dir");

		xstream.aliasAttribute(Arrival.class, "locationId", "locid");
		xstream.aliasAttribute(Arrival.class, "direction", "dir");
		xstream.aliasAttribute(Arrival.class, "scheduledStopTime", "scheduled");
		xstream.aliasAttribute(Arrival.class, "estimatedStopTime", "estimated");
		xstream.aliasAttribute(Arrival.class, "shortsign", "shortSign");
		xstream.aliasAttribute(Arrival.class, "fullsign", "fullSign");
		xstream.aliasAttribute(Arrival.class, "status", "status");
		xstream.aliasAttribute(Arrival.class, "route", "route");
		xstream.aliasAttribute(Arrival.class, "detour", "detour");
		xstream.aliasAttribute(Trip.class, "description", "desc");

		xstream.registerConverter(new ResponseConverter(), XStream.PRIORITY_VERY_HIGH);
 		xstream.registerConverter(new CalendarConverter(), XStream.PRIORITY_VERY_HIGH);
		
		return xstream;
		
	}
}
